class Solution {
public:
    constexpr static int mod=1e9+7;
    static const int maxn=1e5+10;
    int dp[maxn],last[2];
    int numberOfUniqueGoodSubsequences(string a) {
        int n=a.size();
        last[0]=last[1]=-1;
        int add=0;
        for(int i=1;i<=n;++i) {
            int cur=a[i-1]-'0';
            add|=!cur;
            if(last[cur]==-1) {
                if(!cur) dp[i]=(dp[i-1]*2)%mod;
                else dp[i]=(dp[i-1]*2+1)%mod;
            } else {
                dp[i]=(dp[i-1]*2-dp[last[cur]-1])%mod;
                dp[i]+=mod;
                dp[i]%=mod;
            }
            last[cur]=i;
        }
        return (dp[n]+add)%mod;
    }
};